<?php
namespace Admin\Controller;
use Think\Controller;
class UserController extends CommonController {
    public function index(){

         $auth = new \Think\Auth();
        var_dump($auth->check( 'is_stop', 1 ));

        if($_POST){
            $start = strtotime(I('post.start'));
            $end = strtotime(I('post.end'));
            $nickname = I('post.nickname');

            $sql ="select * from user where create_time>'{$start}' and create_time<'{$end}' and nickname like '%{$nickname}%'";


            $users = M('user')->query($sql);


        }else{
            $users = M('user')->select();
             
        }

        $this->assign('users',$users);
        $this->display(); 
    	
    }
    public function memberstop()
    {

       

    	$uid = I('post.uid');

    	if(M('user')->where(array('id'=>$uid))->save(array('stop'=>1))){
    		$arr = array(
    			'error'=>0,
    			'info'=>'已停用'
    			);
    		echo json_encode($arr);
    		exit;

    	}else{
    		$arr = array(
    			'error'=>1,
    			'info'=>'停用失败'
    			);
    		echo json_encode($arr);
    		exit;
    	}
    }
    public function delall()
    {
        $ids  = I('post.ids');
       $sql = "delete from user where id in (".$ids.")";

       var_dump($sql);
    }

    public function so()
    {
        $sql = "select * from user where create_time>'1490976000' and create_time<'1493308800' and nickname like '%小明%'";

        $users = M('user')->query($sql);

        echo json_encode($users);

    }
}